<template>
  <div>
    <!-- 面包屑组件 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <!-- 需要用native属性 -->
      <el-breadcrumb-item :to="{ path: '/home' }" @click.native="returnHome"
        >首页</el-breadcrumb-item
      >
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card>
      <!-- 权限列表 -->
      <el-table :data="rightsList" style="width: 100%" border stripe>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column prop="level" label="权限等级"></el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'Rights',
  data () {
    return {
      rightsList: []
    }
  },
  methods: {
    // 依然是点击首页的优化
    returnHome () {
      this.$bus.$emit('changePath')
    },
    async getRightsList () {
      const { data: res } = await this.$https.get('rights/list')
      if (res.meta.status === 200) {
        this.rightsList = res.data
      } else this.$message.error('数据请求失败！')
    }
  },
  created () {
    // 创建时请求权限数据列表
    this.getRightsList()
  }
}
</script>

<style>
</style>
